package com.solution.admin.customer.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.solution.admin.customer.dao.DeliveryModeDao;
import com.solution.admin.customer.entity.DeliveryModeEntity;
import com.solution.admin.customer.service.DeliveryModeService;

import com.solution.common.dao.BaseDao;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;
import com.solution.common.service.impl.BaseServiceImpl;
import com.solution.common.utils.string.StringUtil;

/**
 * 单位配件方式service实现层
 * @author solin
 * @date 2017-10-29 21:56:05
 */
@Service
public class DeliveryModeServiceImpl extends BaseServiceImpl<DeliveryModeEntity> implements DeliveryModeService {

	/**
	 * 单位配件方式接口
	 */
	@Autowired
	private DeliveryModeDao deliveryModeDao;

	protected BaseDao<DeliveryModeEntity> getDao() {
		return this.deliveryModeDao;
	}

	/**
	 * 保存单位配件方式
	 * @param deliveryModeEntity 单位配件方式实体
	 * @return Long 添加成功单位配件方式的ID
	 * @author solin
	 * @date 2017-10-29 21:56:05
	 */
	public long saveDeliveryMode(List<DeliveryModeEntity> deliveryModeList) {
		deliveryModeDao.deleteDeliveryModeByCompanyId(deliveryModeList.get(0).getCompanyId());
		return deliveryModeDao.batchSaveDeliveryMode(deliveryModeList);
	}

	/**
	 * 分页查询单位配件方式
	 * @param pageParam 分页参数
	 * @param paramMap 查询参数
	 * @return PageBean 分页参数和分页数据
	 * @author solin
	 * @date 2017-10-29 21:56:05
	 */
	@Override
	public PageBean listDeliveryModePage(PageParam pageParam, Map<String, Object> paramMap) {
		return deliveryModeDao.listDeliveryModePage(pageParam, paramMap);
	}
	
	/**
	 * 根据ID查询用户信息
	 * @param id 用户id
	 * @return deliveryModeEntity 用户对象
	 * @author solin
	 * @date 2017-10-29 21:56:05
	 */
	public DeliveryModeEntity getDeliveryModeById(Long id) {
		return deliveryModeDao.getById(id.longValue());
	}

	/**
	 * 更新用户
	 * @param deliveryModeEntity 用户实体
	 * @return Long 更新是否成功，>1代表更新成功
	 * @author solin
	 * @date 2017-10-29 21:56:05
	 */
	@Override
	public int updateDeliveryMode(DeliveryModeEntity deliveryModeEntity) {
		return deliveryModeDao.updateDeliveryMode(deliveryModeEntity);
	}
	
	
	/**
	 * 根据条件查询单位配件方式
	 * @param param
	 * @return 数据列表
	 * @author solin
	 * @date 2017-10-29 21:56:05
	 */
	@Override
	public List<DeliveryModeEntity> listDeliveryMode( Map<String, Object> param){
		return  deliveryModeDao.listDeliveryMode(param);
	}
	
	/**
	 * 删除单位配件方式
	 * @param 
	 * @return int 返回删除记录条数
	 * @author solin
	 * @date 2017-10-29 21:56:05
	 */
	public int deleteDeliveryModeById(long id){
		return  deliveryModeDao.deleteById(id);
	}
	
}
